package cn.tedu;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;


@Component //新增：标记当前类为组件      隐式创建    实例化
public class User{


//    @Resource(type = IPhone.class)
    private Phone phone;

    @Autowired//自动装配
//    @Resource
    public User(@Qualifier("huaweiPhone")Phone phone){
        this.phone=phone;
    }

    public User() {
        System.out.println("User类的构造方法被调用了");
    }

    public void playGame(){
        System.out.println("正在通过【"+phone.getName()+"】玩游戏");
    }

}
